<%@ page language="java"
         import="java.util.List"
         pageEncoding="utf-8" %>
<%@ page import="org.whuims.pois.action.result.ClusterVo" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <base href="<%=basePath%>">

    <title>${sessionScope.topicName} - 舆情信息系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <%@include file="../im.jsp" %>
    <!--添加jqPlot支持-->
    <!--[if lt IE 9]>
    <script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]-->
    <script language="javascript" type="text/javascript" src="js/jquery.jqplot.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/jquery.jqplot.css"/>
    <script type="text/javascript" src="js/jqplot.canvasTextRenderer.min.js"></script>
    <script type="text/javascript" src="js/jqplot.canvasAxisLabelRenderer.min.js"></script>
    <script type="text/javascript" src="js/jqplot.dateAxisRenderer.min.js"></script>
    <script type="text/javascript" src="js/jqplot.canvasTextRenderer.min.js"></script>
    <script type="text/javascript" src="js/jqplot.canvasAxisTickRenderer.min.js"></script>
    <script type="text/javascript" src="js/jqplot.categoryAxisRenderer.min.js"></script>
    <script type="text/javascript" src="js/jqplot.barRenderer.min.js"></script>
    <style type="text/css">
        .ProgressBar {
            float: left;
            width: 60px; /* 宽度 */
            border: 1px solid #B1D632;
            padding: 1px;
            margin: 2px 10px;
        }

        .ProgressBar div {
            display: block;
            position: relative;
            background: #B1D632;
            color: #333333;
            font-size: 10px;
            height: 11px; /* 高度 */
            line-height: 11px; /* 必须和高度一致，文本才能垂直居中 */
        }

        .ProgressBar div span {
            position: absolute;
            width: 60px; /* 宽度 */
            text-align: center;
        }
    </style>

</head>

<body>
<logic:equal name="user" value="administrator">
    <%
        List<ClusterVo> clusterList = (List<ClusterVo>) request.getAttribute("topic");
        int max = 20;
        if (clusterList!=null){
            if (clusterList.size() > 0) {
                max = clusterList.get(0).getCount();
            }
        }
        request.setAttribute("max", max);
    %>
    <div id="content" class="container">
        <%@include file="../top.jsp" %>
        <div class="row">
            <%@include file="../left.jsp" %>
            <div class="col-md-10">
                <!--图表-->
                <div class="row">
                    <div class="left_articles col-md-9">
                            <%--<iframe width="780" height="242" style="border:none;" frameborder=0--%>
                            <%--src="iframe/timeseriesindex/timeseriesindex.html"></iframe>--%>
                        <div id="hello">
                            <div>
                                <input type="radio" name="type" value="news" checked/>新闻&nbsp;
                                <input type="radio" name="type" value="bbs"/>论坛&nbsp;
                                <input type="radio" name="type" value="weibo"/>微博&nbsp;
                                <input type="radio" name="type" value="blog"/>博客&nbsp;
                                <script type="text/javascript">
                                    $("input[name=type][value=${type}]").attr("checked", true);
                                </script>

                            </div>
                            <script type="text/javascript">
                                var typeIndex = 0;
                                $("input:radio[name=planguage]:nth(0)").attr("checked", true);
                                function languageRadioIndex(planguge) {
                                    if (planguge == 'all' || planguge == '') {
                                        typeIndex = 0;
                                    } else if (planguge == 'chi') {
                                        typeIndex = 1;
                                    } else if (planguge == 'en') {
                                        typeIndex = 2;
                                    } else if (planguge == 'jp') {
                                        typeIndex = 3;
                                    }
                                }
                                timeserial("news");
                                function timeserial(type) {
                                    //Ajax请求
                                    $.ajax({
                                        type: 'post',
                                        url: 'todayTimeSerial.aj',
                                        data: {
                                            type: type
                                        }, success: function (data) {
                                            renderTimeSerial(data);
                                        }
                                    });
                                }
                                $("input:radio[name=type]").click(function () {
                                    var type = $('input:radio[name=type]:checked').val();
                                    timeserial(type);
                                });

                            </script>
                            <div class="titlebox" style="border-bottom: 1px solid darkgray; padding:0 3px;">
                                <div class="title"></div>
                            </div>
                            <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto">
                                <!--这里显示图表-->
                            </div>
                            <script type="text/javascript">
                                function renderTimeSerial(data) {
                                    if (data == '') {
                                        var sp = $("#container").append("span");
                                        sp.css("text-align", "center");
                                        sp.css("height", "400px");
                                        sp.html("没有数据");
                                    } else {
                                        data = eval("'" + data + "'");
                                        data = jQuery.parseJSON(data);
                                        $("#container").html("");
                                        var plot2 = $.jqplot('container', data, {
                                            series: [
                                                {xaxis: 'xaxis', yaxis: 'yaxis'}
                                            ],
                                            axesDefaults: {
                                                tickRenderer: $.jqplot.CanvasAxisTickRenderer,
                                                tickOptions: {
                                                    angle: -45
                                                }
                                            },
                                            axes: {
                                                xaxis: {
                                                    renderer: $.jqplot.CategoryAxisRenderer
                                                },

                                                yaxis: {
                                                    autoscale: true
                                                }

                                            }
                                        });
                                    }

                                }

                            </script>
                        </div>
                    </div>
                    <div class="col-md-3">
                            <%--<div class="thirds">
                                <div class="smallboxtop"></div>
                                <div class="smallbox" style="padding:0;">
                                    <p>
                                        <b>&nbsp;&nbsp;热点人物</b>
                                    </p>
                                    <!-- 输出热点人物
                                        <embed tplayername="SWF" splayername="SWF" type="application/x-shockwave-flash"
                                         src="mainpage/tagcloudpoms.swf?r=8269298" mediawrapchecked="true"
                                         pluginspage="http://www.macromedia.com/go/getflashplayer"
                                         id="tagcloudflash" name="tagcloudflash" bgcolor="#ffffff"
                                         quality="high" wmode="transparent" allowscriptaccess="always"
                                         flashvars="tcolor=0xffffff&amp;tcolor2=0x999999&amp;hicolor=0xffffff&amp;tspeed=100&amp;distr=true"
                                          width="250" height="250">
                                    </embed>
                                     -->

                                    <%
                                        String searchTitle = basePath + "searchPersonAction.do?keyword=";
                                        //System.out.println(searchTitle);


                                        List<PersonCloudBean> tagList = new ArrayList<PersonCloudBean>();
                                        tagList = new PersonCloudDao().getPersonTags();
                                        Collections.sort(tagList, new Comparator<PersonCloudBean>() {
                                            public int compare(PersonCloudBean bean1,
                                                               PersonCloudBean bean2) {
                                                if (bean1.getOccurtimes() < bean2.getOccurtimes()) {
                                                    return 1;
                                                } else {
                                                    return -1;
                                                }
                                            }
                                        });
                                        StringBuilder cloudBuilder = new StringBuilder("<tags>");
                                        int size = tagList.size() > 20 ? 20 : tagList.size();
                                        for (int i = 0; i < 15 && i < tagList.size(); i++) {
                                            String randomColor = "0x";
                                            for (int j = 0; j < 6; j++) {
                                                int random = new Double(16 * Math.random()).intValue();
                                                if (random < 10)
                                                    randomColor += random;
                                                else {
                                                    switch (random) {
                                                        case 10:
                                                            randomColor += 'a';
                                                            break;
                                                        case 11:
                                                            randomColor += 'b';
                                                            break;
                                                        case 12:
                                                            randomColor += 'c';
                                                            break;
                                                        case 13:
                                                            randomColor += 'd';
                                                            break;
                                                        case 14:
                                                            randomColor += 'e';
                                                            break;
                                                        case 15:
                                                            randomColor += 'f';
                                                            break;
                                                        default:
                                                            ;
                                                    }
                                                }
                                            }
                                            //System.out.println(randomColor);

                                            PersonCloudBean tagBean = tagList.get(i);
                                            cloudBuilder.append("<a href='" + searchTitle + tagBean.getKeyword() + "' style='" + (2 * tagBean.getOccurtimes() + 20) + "' color='" + randomColor + "'  hicolor='0x00cc00'>");
                                            cloudBuilder.append(tagBean.getKeyword() + "</a>");

                                        }
                                        cloudBuilder.append("</tags>");
                                    %>
                                    <div id="flashcontent"></div>
                                    <script type="text/javascript">
                                        var so = new SWFObject("mainpage/tagcloud.swf", "tagcloud", "250", "250", "7", "#ffffff");
                                        // uncomment next line to enable transparency
                                        so.addParam("wmode", "transparent");
                                        so.addVariable("tcolor", "0x333333");
                                        so.addVariable("mode", "tags");
                                        so.addVariable("distr", "true");
                                        so.addVariable("tspeed", "100");
                                        so.addVariable("tagcloud", "<%=cloudBuilder.toString()%>");
                                        so.write("flashcontent");
                                    </script>

                                </div>
                            </div>--%>
                        <p class="text-center"><strong>我的关注</strong></p>
                        <!-- 输出我的关注 -->
                        <div style="border-left: 1px dashed #808080;padding-left: 15px">
                            <%@include file="myfocus.jsp" %>
                        </div>

                    </div>
                </div>
                <div class="row" style="margin-top: 10px">

                    <div class="col-md-6">
                        <div class="panel panel-primary">
                            <!-- 输出最新新闻 -->
                            <div class="panel-heading">
                                <strong>最新新闻</strong>
                                <a href="newsAction.do?method=newest"><span class="label label-danger pull-right">more</span></a>
                            </div>
                            <!-- 标题title -->
                            <div class="panel-body">
                                <logic:present name="news" scope="request">
                                    <div class="media-list">
                                        <logic:iterate id="newest" name="news" length="4">
                                            <!-- 标题title -->
                                            <li class="media" style="margin-top: 0px;">
                                                <h5>
                                                    <html:link page="/logAction.do" paramId="link"
                                                               paramName="newest" paramProperty="link" target="_blank">
                                                        <logic:notEqual name="newest" property="title" value="">
                                                            <bean:write name="newest" property="title"
                                                                        filter="true"/>
                                                        </logic:notEqual>
                                                        <logic:equal name="newest" property="title" value="">暂无标题</logic:equal>
                                                    </html:link>
                                                </h5>
                                                <!-- 输出时间 -->
                                                <small>
                                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                                    <logic:notEqual name="newest" property="time" value="">
                                                        [<bean:write name="newest" property="time"/>]
                                                    </logic:notEqual>
                                                    <!-- 输出站点 -->
                                                    [<bean:write name="newest" property="site"></bean:write>]
                                                </small>
                                                <!-- 输出摘要 -->
                                                <p>
                                                    <bean:write name="newest" property="abstext" filter="true"/>
                                                </p>
                                            </li>
                                        </logic:iterate>
                                    </div>
                                </logic:present>
                            </div>
                        </div>


                            <%--<div class="boxtop"></div>--%>
                        <div style="clear: both;"></div>
                            <%-- <div class="box">

                                 <!-- 输出负面新闻 -->
                                 <div class="titlebox">
                                     <div class="title">
                                         <b>负面新闻</b>
                                     </div>
                                     <div class="buttons">

                                         <a href="newsAction.do?method=negetive" class="bluebtn">更多</a>
                                     </div>
                                 </div>
                                 <!-- 标题title -->

                                 <logic:present name="negNews" scope="request">
                                     <logic:iterate id="newest" name="negNews" length="3">
                                         <!-- 标题title -->
                                         <h4>

                                             <div class="add">
                                                 <a class="add" href="#"></a>
                                             </div>
                                             <html:link page="/logAction.do" paramId="link"
                                                        paramName="newest" paramProperty="link" target="_blank">
                                                 <logic:notEqual name="newest" property="title" value="">
                                                     <bean:write name="newest" property="title"
                                                                 filter="true"/>
                                                 </logic:notEqual>
                                                 <logic:equal name="newest" property="title" value="">暂无标题</logic:equal>
                                             </html:link>
                                             &nbsp;
                                             <!-- 输出时间 -->
                                             <logic:notEqual name="newest" property="newsTime" value="">
                                                 [<bean:write name="newest" property="newsTime"/>]
                                             </logic:notEqual>
                                             <!-- 输出站点 -->
                                             [<bean:write name="newest" property="siteName"></bean:write>]
                                         </h4>
                                         <!-- 输出摘要 -->
                                         <p>
                                             <bean:write name="newest" property="abstext" filter="true"/>
                                         </p>
                                     </logic:iterate>
                                 </logic:present>
                             </div>--%>


                    </div>
                    <div class="col-md-6">
                        <div class="panel panel-primary">

                            <!-- 输出最新新闻 -->
                            <div class="panel-heading">
                                <strong>今日要点</strong>
                                <a href="clusterAction.do?method=today"><span class="label label-danger pull-right">more</span></a>
                            </div>
                            <!-- 标题title -->
                            <div class="panel-body">
                                <logic:present name="topic" scope="request">
                                <div class="media-list">
                                    <logic:iterate id="newest" name="topic" length="4">
                                        <!-- 标题title -->
                                        <li class="media" style="margin-top: 0px;">
                                            <div class="row">
                                                <div class="col-md-9">
                                                    <h5>
                                                        <html:link page="/logAction.do" paramId="link"
                                                                   paramName="newest" paramProperty="link" target="_blank">
                                                            <logic:notEqual name="newest" property="title" value="">
                                                                <bean:write name="newest" property="title"
                                                                            filter="true"/>
                                                            </logic:notEqual>
                                                            <logic:equal name="newest" property="title" value="">暂无标题</logic:equal>
                                                        </html:link>

                                                    </h5>
                                                </div>
                                                <div class=" col-md-3" style="margin-top: 10px;">
                                                    <div class="ProgressBar">
                                                        <html:link page="/newsAction.do?method=similar"
                                                                   paramId="similarId" paramName="newest"
                                                                   paramProperty="id">
                                                            <%--<div class="progress progress-striped  active">--%>
                                                            <%--<div class="progress-bar progress-bar-success" role="progressbar"--%>
                                                            <%--aria-valuenow="40" aria-valuemin="0" aria-valuemax="100"--%>
                                                            <%--style="width: ${newest.count * 100 / max }%">--%>
                                                            <%--<span class="sr-only"><bean:write name="newest"--%>
                                                            <%--property="count"/></span>--%>
                                                            <%--</div>--%>

                                                            <div style="width: ${newest.count * 100 / max }%">
                                                                <span><bean:write name="newest" property="count"/></span>
                                                            </div>

                                                            <%--</div>--%>
                                                        </html:link>
                                                    </div>
                                                </div>

                                            </div>

                                            <!-- 输出时间 -->
                                            <small>
                                                &nbsp;&nbsp;&nbsp;&nbsp;
                                                <logic:notEqual name="newest" property="crawltime" value="">
                                                    [<bean:write name="newest" property="crawltime"/>]
                                                </logic:notEqual>
                                            </small>
                                            <!-- 输出摘要 -->
                                            <p>
                                                <bean:write name="newest" property="abstext" filter="true"/>
                                            </p>
                                        </li>
                                    </logic:iterate>
                                </div>
                            </div>
                            </logic:present>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--end of right-->
    <div class="footer">
        <%@ include file="../foot.jsp" %>
    </div>
    </div>
</logic:equal>
<logic:empty name="user">
    Access Rejected! Error 404
</logic:empty>
</body>
</html>
